package com.eh.proxy.remote.client;

import com.eh.proxy.remote.remote.model.GumballMachineRemote;

import java.rmi.RemoteException;

/**
 * Created by David on 2016/5/2.
 */
public class GumballMachineMonitor {
    private GumballMachineRemote machine;

    public GumballMachineMonitor(GumballMachineRemote machine) {
        this.machine = machine;
    }

    private static int statusCode = 1;

    public void report() {
        try {
            if (statusCode > 0) {
                System.out.printf("%s\t%d\t%s%n", machine.getLocation(), machine.getCount(), machine.getCurrentState());
                if (machine.getCount() == 0) {
                    statusCode = 0;
                }
            }

        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
